package service

import (
	"common_demo/internal/server/handler"
	"net/http"

	"github.com/gin-gonic/gin"
)

type Logic struct {
	Handler *handler.Handler
}

func (l *Logic) Ping(c *gin.Context) {
	c.JSON(http.StatusOK, "Pong")
}

func (l *Logic) Ws(c *gin.Context) {
	l.Handler.Ws(c)
}

func (l *Logic) GetNamespaces(c *gin.Context) {
	namespaces, err := l.Handler.GetNamespaces(c)
	if err != nil {
		c.JSON(http.StatusBadRequest, nil)
	} else {
		c.JSON(http.StatusOK, namespaces)
	}
}

func (l *Logic) AddThings(c *gin.Context) {
	l.Handler.AddThings(c)
}
